package com.lepu.app.fun.my;

import java.util.ArrayList;

import android.os.Bundle;
import android.widget.ListView;

import com.core.lib.application.BaseFragmentActivity;
import com.core.lib.utils.main.AppManager;
import com.lepu.app.fun.my.adapter.AdapterMyUserInfoIllHistory;
import com.lepu.app.usercenter.bean.LoginInfoIllnessTags;
import com.lepu.app.widget.CustomTopBarNew;
import com.lepu.app.widget.CustomTopBarNew.OnTopbarNewLeftLayoutListener;
import com.lepu.app.widget.CustomTopBarNew.OnTopbarNewRightButtonListener;
import com.lepu.pasm.R;

public class MyUserInfoIllHistoryActivity extends BaseFragmentActivity implements
		OnTopbarNewLeftLayoutListener,OnTopbarNewRightButtonListener {

	private ArrayList<LoginInfoIllnessTags> mDataArray = new ArrayList<LoginInfoIllnessTags>();
	
	public ArrayList<LoginInfoIllnessTags> mSelectedList = new ArrayList<LoginInfoIllnessTags>();
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_userinfo_ill_history_activity);

		init();
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
	}

	/**
	 * 添加页面动画，需要重写这个方法，
	 */
	@Override
	public void onBackPressed() {
		finish(true);
	}
	
	@Override
	public void onTopbarLeftLayoutSelected() {
		finish(true);
	}
	
	@Override
	public void onTopbarRightButtonSelected() {
		save();
	}

	/**
	 * 初始化方法
	 */
	private void init() {
		// topbar
		CustomTopBarNew topbar = (CustomTopBarNew) findViewById(R.id.topbar);
		topbar.setTopbarTitle("病史");
		topbar.setonTopbarNewLeftLayoutListener(this);
		topbar.setRightText("完成");
		topbar.setOnTopbarNewRightButtonListener(this);
		
		String[] idArray = getResources().getStringArray(R.array.array_userinfo_ill_history_title_id);
		String[] tagArray = getResources().getStringArray(R.array.array_userinfo_ill_history_title_tag);
		for(int i=0;i<idArray.length;i++)
		{
			LoginInfoIllnessTags item = new LoginInfoIllnessTags();
			item.TagID = idArray[i];
			item.TagTitle = tagArray[i];
			mDataArray.add(item);
		}
		
		ListView dataListView = (ListView) findViewById(R.id.dataListView);
		dataListView.setAdapter(new AdapterMyUserInfoIllHistory(this, mDataArray,dataListView));
	}

	private void save()
	{
		MyUserInfoActivity instance = (MyUserInfoActivity) AppManager.getAppManager().getActivity(MyUserInfoActivity.class);
		if(instance != null)
		{
			instance.setIllHistory(mSelectedList);
			finish(true);
		}
	}

}
